package com.tensquare.sms.listenter;

import com.aliyuncs.exceptions.ClientException;
import com.tensquare.sms.util.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "sms")
public class SmsListener {
    @Autowired
    private SmsUtil smsUtil;
    @Value("templete_code")
    private String templete_code;
    @Value("sige_name")
    private String sige_name;

    @RabbitHandler
    public  void executsMsg(Map<String,String> map) throws ClientException {
        System.out.println("手机号"+map.get("mobile"));
        System.out.println("验证码"+map.get("checkcode"));

        smsUtil.sendSms(map.get("mobile"),map.get("checkcode"),templete_code,"{\"checkcode\":\""+map.get("checkcode")+"\"}");
    }


}
